const fs = require('fs')
const path = require('path')

fs.readdir('./images', (error, files) => {
    if(!error) {
        const list = files.map(filePath => {
            let fPath = path.resolve(__dirname, 'images', filePath)
            let data = fs.readFileSync(fPath)
            data = Buffer.from(data).toString('base64')
            return `data:image/png;base64,${data}`
        })
        fs.writeFile('emoji.js', `const emojiList = ${JSON.stringify(list)}`, err => {
            if (err) throw err
            process.stdout.write('创建成功!')
          })
    }
})